from systems.models import Setting, SettingType, Menu
from systems.serializers import SettingSerializer, SettingTypeSerializer, MenuSerializer
from mes_api.utils.base_viewsets import BaseViewSet

# from .filters import UserFilter


class SettingViewSets(BaseViewSet):
    filterset_fields = ('status', 'type')
    search_fields = ('name', 'id', 'title')
    # 排序
    ordering_fields = ('name', 'id', 'title', 'update_time',
                       'create_time', 'status')
    queryset = Setting.objects
    serializer_class = SettingSerializer


class SettingTypeViewSets(BaseViewSet):

    filterset_fields = ('status', 'setting__name',
                        'setting__status', 'title')
    search_fields = ('name', 'id', 'title')
    # 排序
    ordering_fields = ('name', 'id', 'title', 'update_time',
                       'create_time', 'status')
    queryset = SettingType.objects
    serializer_class = SettingTypeSerializer


class MenuViewSets(BaseViewSet):

    filterset_fields = ('name', 'component',
                        'title')
    search_fields = ('name', 'id', 'path', 'component', 'title')
    # 排序
    ordering_fields = ('name', 'id', 'update_time',
                       'create_time', 'status')
    queryset = Menu.objects
    serializer_class = MenuSerializer
